package com.ccrc.demo;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.ccrc.bo.PerBaseBo;
import com.ccrc.service.PerBaseService;
import com.google.common.collect.Lists;

/**
 * 
 */

/**
 * @author Jalen
 *
 */
public class Consumer {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:dubbo-consumer.xml");
		context.start();
		
		try {
			DemoService ds = (DemoService) context.getBean("demoService");
			String[] names = context.getBeanDefinitionNames();
			System.out.print("Beans:");
			for (String string : names) {
				System.out.print(string);
				System.out.print(",");
			}
			System.out.println();

			MsgInfo info = new MsgInfo();
			info.setId(1);
			info.setName("ruisheh");
			List<String> msgs = Lists.newArrayList();
			msgs.add("I");
			msgs.add("am");
			msgs.add("test");
			info.setMsgs(msgs);

			System.out.println(ds.returnMsgInfo(info).getMsgs());
			
			System.out.println(StringUtils.center("根据perId和rptDate查询基本信息", 50, "#"));
			
			PerBaseService pbs = (PerBaseService) context.getBean("perBaseService");
			String perid = "1"; 
			String rptDate = "2016-12-01 00:00:00";
			
			PerBaseBo dto = pbs.getPerBase(perid, rptDate);
			
			System.out.println("PerBaseDto=="+dto.toString());
		} catch (Exception e) {
			e.printStackTrace();
			
		} finally {
			if(context.isActive()){
				context.close();
			}
		}
		
	}

}
